<!-- 分类授权编辑页面 -->
<extend name="Public/layout" />
<block name="body">

<style>
    .checkbox_{ margin:3px 6px; height:30px; line-height:30px; padding-left:5px; }
    .bd .checkbox_{ font-weight:100; }
    .hd{ background:#ecf0f5; }
    .fr{ float:right !important;margin-top:14px;right:20px; }
</style>

    <div class="nav-tabs-custom flat">
        <ul class="nav-tabs nav">
            <li><a href="{$accessUrl}" class="pjax">访问授权</a></li>
            <li class="active"><a href="javascript:;">分类授权</a></li>
            <li class="fr" style="margin:2px 0 0 0;"> <a>{$groupName}</a> </li>
        </ul>
        <!-- 表格列表 -->
        <div class="tab-content">
            <form id="jform" class="save-category" action="" method="post" enctype="application/x-www-form-urlencoded">
                <input type="hidden" name="group_id" value="{:I('group_id')}">
                <div class="category auth-category">
                    {:$__CTL__->_tree($group_list)}
                </div>
                <div class="tab-footer text-center">
                    <button type="submit" class="btn btn-flat _dt_btns_  btn-primary"><i class="fa fa-save"></i> 保存</button> 　
                    <button  class="btn btn-default btn-flat" onclick="javascript:history.back();return false;" data-dismiss="modal"><i class="fa fa-ban"></i> 取消</button>&nbsp;&nbsp;
                </div>

            </form>
        </div>
    </div>
    <!-- /表格列表 -->

    <script type="text/javascript">
        + function($) {
            /* 分类展开收起 */
            $(".category dd").prev().find(".fold i").addClass("icon-unfold").click(function() {
                var self = $(this);
                if (self.hasClass("icon-unfold")) {
                    self.closest("dt").next().slideUp("fast", function() {
                        self.removeClass("icon-unfold").addClass("icon-fold");
                    });
                } else {
                    self.closest("dt").next().slideDown("fast", function() {
                        self.removeClass("icon-fold").addClass("icon-unfold");
                    });
                }
            });

            var auth_groups = [{$authed_group}];
            $('.cate_id').each(function() {
                if ($.inArray(parseInt(this.value, 10), auth_groups) > -1) {
                    $(this).prop('checked', true);
                }
            });

            $('select[name=group]').change(function() {
                location.href = this.value;
            });

            $('#jform').submit(AjaxFrom);
        }(jQuery);
    </script>

</block>
